<?php

function bacaHTML($url) {

    // inisialisasi CURL
    $data = curl_init();
    // setting CURL
    curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($data, CURLOPT_URL, $url);
    // menjalankan CURL untuk membaca isi file
    $hasil = curl_exec($data);
    curl_close($data);
    return $hasil;
}

echo "http://www.utiket.com/indonesia/cari/penerbangan-$bandara_a-$bandara_t-" . $date . "00001R.html";
echo "<br>";
echo "http://www.utiket.com/indonesia/cari/penerbangan-Jakarta-CGK-Denpasar%20Bali-DPS-040900001R.html?RouteSessionId=041220121713204701458215";
$kodeHTML = bacaHTML("http://www.utiket.com/indonesia/cari/penerbangan-$bandara_a-$bandara_t-" . $date . "00001R.html?RouteSessionId=");
//$kodeHTML = bacaHTML("http://www.utiket.com/indonesia/cari/penerbangan-Jakarta-CGK-Denpasar%20Bali-DPS-040900001R.html");
//
$pecah = explode('<div class="airlineprice"  >', $kodeHTML);
$pecah2 = explode('</div>', $pecah[1]);
$pecah3 = explode('<em class="sortonthis"  >', $pecah2[0]);
$pecah4 = explode('</em>', $pecah3[1]);

$nama3 = explode('<span>', $pecah2[2]);
$nama4 = explode('</span>', $nama3[1]);

$count = count($pecah);
?>

<table>
    <tr>
        <td>Maskapai</td><td>Harga</td>
        <td>Pilih</td>
    </tr>
    <?php
    for ($i = 1; $i < $count; $i++) {
        $pecah2 = explode('</div>', $pecah[$i]);
        $pecah3 = explode('<em class="sortonthis"  >', $pecah2[0]);
        $pecah4 = explode('</em>', $pecah3[1]);

        $nama3 = explode('<span>', $pecah2[2]);
        $nama4 = explode('</span>', $nama3[1]);
        echo "<tr>";
        echo "<td>" . $nama4[0] . "</td>";
        echo "<td>" . $pecah4[0] . ".000</td>";
        echo "<td><a href=costumer/$pecah4[0].$nama4[0]>Pesan</a></td>";
        echo "</tr>";
    }
    ?>
</table>

